#![allow(unused)]

use std::collections::HashMap;

use ts_rs::TS;

#[derive(TS)]
#[ts(export, export_to = "issue_168/")]
pub struct Foo {
    map: HashMap<usize, Bar>,
}

#[derive(TS)]
#[ts(export, export_to = "issue_168/")]
pub struct FooInlined {
    #[ts(inline)]
    map: HashMap<usize, Bar>,
}

#[derive(TS)]
#[ts(export, export_to = "issue_168/")]
struct Bar {
    #[ts(inline)]
    map: HashMap<usize, Baz>,
}

#[derive(TS)]
#[ts(export, export_to = "issue_168/")]
struct Baz {
    #[ts(inline)]
    map: HashMap<usize, String>,
}

#[test]
#[cfg(not(feature = "import-esm"))]
fn issue_168() {
    assert_eq!(
        FooInlined::export_to_string().unwrap(),
        "// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\
         \n\
         export type FooInlined = { map: { [key in number]?: { map: { [key in number]?: { map: { [key in number]?: string }, } }, } }, };\n"
    );
    assert_eq!(
        Foo::export_to_string().unwrap(),
        "// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.\n\
         import type { Bar } from \"./Bar\";\n\
         \n\
         export type Foo = { map: { [key in number]?: Bar }, };\n"
    );
}
